/*********************************************************
          File Name:9.5.cpp
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Mon 14 Sep 2015 04:30:54 PM CST
**********************************************************/

#include <iostream>
#include <vector>
#include <list>

using std::vector;
using std::list;
using std::cout;
using std::endl;

using type = vector<int>::iterator;

type find(type begin, type end, int target)
{
        type tmp = begin;

        for(; tmp != end; ++tmp)
                if(*tmp == target)
                        return tmp;
        return end;
}

int main()
{
        vector<int> v{1,2,3,4,5,6,7,8};

        auto res = find(v.begin(), v.end(), 9);

        cout << ((res == v.end()) ? "not found" : "found") << endl;

        v = {1, 2, 3};
        for(auto const &x: v)
                cout << x << endl;

        list<int> ls;
        ls.assign(v.cbegin(), v.cend());        // const_iterator

        for(auto const &x: ls)
                cout << x << endl;

        return 0;
}
